Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

175
Visualizações
"Missing semicolon" error on Async function declaration

In a Vue app, I want to group js functions in a js file. In getData.js , I have the following:

import { collection, getDocs } from 'firebase/firestore/lite';
import { db } from "./firebase/index";
import store from "../store/index"

  
  async getProjects () { 
    const querySnapshot = await getDocs(collection(db, "projects"));
      querySnapshot.forEach((doc) => {
      let project = doc.data()
      project.id = doc.id
      store.state.currentProjectList.push(project)
    });
  }



  export { getProjects } 

I get the "Missing semicolon." error on the line where I declare the function: async getProjects().

(I know this isn't the way to add data to the store but this is only for testing purpose)

Thanks for any help!

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

async getProjects () { is method declaration syntax; it is only allowed inside an object or class definition.

To create a local function you need to use a function declaration or an arrow function.

async function getProjects () { 

or

const getProjects = async () => {

(You could also use a function expression, but that gets even further from the syntax you had).


You also have a missing semi-colon at the of the previous line – import store from "../store/index" which isn't a JS error (but might be a linting error if you are using a linter and didn't mention that).

about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda